package com.zlh.mq;

import com.zlh.config.Config;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
@RocketMQMessageListener(topic = "test-Topic", consumerGroup = "test-Group",
//        accessKey = "LlsydnRocketMQ", secretKey = "Llsydn123!@#",
        messageModel = MessageModel.CLUSTERING
//        , nameServer = "localhost:9876"
)
public class TestConsumer implements RocketMQListener<String> {

    @Autowired
    Config config;
    @Override
    public void onMessage(String s) {
//        long st = config.getSleepTime();
        try {
//            Thread.sleep(st);
            System.out.println("currentTime: " + new Date() + ", msg: " + s);
        } catch (Exception e) {
            System.err.println("error");
        }
    }
}
